import {post} from "../untils/db"

Page({
  data: {
    obj: {
      password: "",
      newPassword: "",
      newPassword2: ""
    }
  },
  oldpassword(e) {
    this.setData({
      "obj.password": e.detail.value
    })
  },
  new1password(e) {
    this.setData({
      "obj.newPassword": e.detail.value
    })
  },
  new2password(e) {
    this.setData({
      "obj.newPassword2": e.detail.value
    })
  },
  async emit(){
    let token=wx.getStorageSync('login')
  let res=await post("/api/updatePassword",this.data.obj,token)
  console.log(res);
  if(res.data.code==200){
  
  wx.navigateBack()
  wx.showToast({
    title: '更改成功',
    icon:"success"
  })
  }else{
    wx.showToast({
      title: '原密码错误',
      icon:"error"
    })
  }
  }
})